package demo.app.nexd.com.demo;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Created by lawrence on 2015/12/25.
 */
public class ShoppingActivity extends Activity {

    private WebView webView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shopping_layout);
        webView = (WebView) findViewById(R.id.webView);
        //调用getSettings()设置一些浏览器的属性，调用setJavaScriptEnabled方法来让WebView支持javascript脚本
        webView.getSettings().setJavaScriptEnabled(true);
        String url = getIntent().getStringExtra("url");
        webView.setWebViewClient(new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                view.loadUrl("file://android_assets/" + url);//根据传入的参数在去加载新的网页
                return true;//表示当前WebView可以处理打开新网页的请求，不用借助系统浏览器
            }

        });

        webView.loadUrl("file:///android_asset/" + url);
    }
}
